Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

flatbuffers

Package Overview
Dependencies
Maintainers
3
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

flatbuffers

Memory Efficient Serialization Library

  • 1.12.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
334K
decreased by-13.87%
Maintainers
3
Weekly downloads
 
Created

What is flatbuffers?

FlatBuffers is an efficient cross-platform serialization library for C++, C#, C, Go, Java, JavaScript, TypeScript, PHP, and Python. It allows you to create and access serialized data without parsing/unpacking it, making it ideal for performance-critical applications.

What are flatbuffers's main functionalities?

Creating a FlatBuffer

This code demonstrates how to create a FlatBuffer with a string and a vector of strings. The buffer is then finished and converted to a Uint8Array.

const flatbuffers = require('flatbuffers');
const builder = new flatbuffers.Builder(1024);

// Create a string
const str = builder.createString('Hello, FlatBuffers!');

// Create a vector of strings
const strings = builder.createVectorOfStrings(['foo', 'bar', 'baz']);

// Finish the buffer
builder.finish(strings);

// Get the buffer
const buf = builder.asUint8Array();
console.log(buf);

Reading a FlatBuffer

This code demonstrates how to read a FlatBuffer. It assumes that the buffer contains data for a 'Monster' object, and it accesses the 'name' and 'hp' fields of the object.

const flatbuffers = require('flatbuffers');
const MyGame = require('./mygame_generated'); // Generated code

// Assume buf is a Uint8Array containing the FlatBuffer data
const buf = new Uint8Array([/* FlatBuffer data */]);

// Get the root object
const bb = new flatbuffers.ByteBuffer(buf);
const root = MyGame.Example.Monster.getRootAsMonster(bb);

// Access data
console.log(root.name());
console.log(root.hp());

Other packages similar to flatbuffers

Keywords

FAQs

Package last updated on 12 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc